package com.tuyrt.firstcode.kotlin.dsl

/**
 * Created by tuyrt7 on 2021/4/13.
 */
fun dependencies(block: Dependency.() -> Unit): List<String> {
    val dependency = Dependency()
    dependency.block()
    return dependency.libraries
}

class Dependency {
    val libraries = ArrayList<String>()

    fun implementation(lib: String) {
        libraries.add(lib)
    }
}

fun main() {
    val libraries = dependencies {
        implementation("com.squareup.retrofit2:retrofit:2.9.1")
        implementation("com.squareup.retrofit2:converter-gson:2.9.1")
    }
    for (lib in libraries) {
        println(lib)
    }
}